package com.acane.instagram.pojo;

public class Result {
    private Object data;
    private int code;
    private String msg;
    private int total;

    // 构造函数
    public Result(Object data, int code, String msg, int total) {
        this.data = data;
        this.code = code;
        this.msg = msg;
        this.total = total;
    }

    public Result(Object data, int code, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    // 成功方法
    public static Result success(Object data, int total) {
        return new Result(data, 200, "Success", total);
    }
    public static Result success(Object data) {
        return new Result(data, 200, "Success");
    }

    // 失败方法
    public static  Result failure(int code, String msg) {
        return new Result(null, code, msg);
    }

    public static Result success(Object data, String msg) {
        return new Result(data, 200, msg);
    }

    // Getter 和 Setter 方法
    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getTotal() {
        return total;
    }
    // 设置total字段
    public void setTotal(int total) {
        this.total = total;
    }
    @Override
    public String toString() {
        return "Result{" +
                "data=" + data +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }
}
